<template>
  <!-- 我的收藏 -->
  <div class="star">
    <myheader title="我的文章收藏">
      <div slot="left">
        <van-icon
          name="arrow-left"
          @click="$router.back()"
          slot="left"
        ></van-icon>
      </div>
      <router-link
        class="van-icon van-icon-wap-home-o"
        to="/index"
        slot="right"
      >
      </router-link>
    </myheader>
     <art
     class="single"
                v-for="item in arr"
                :key="item.id"
                :post="item"
              ></art>
   
  </div>
</template>

<script>
import myheader from "@/components/header.vue";
import art from "@/components/articlecard.vue";
export default {
 
  components: {
    myheader,
    art,
  },
  filters: {
    
  },
  data() {
    return {
      id:-1,
      arr:  [],
    };
  },
  methods: {
    //函数
    async getCollectById(id)
    {
       return await this.$http.get("/user/col/" + id);
    }
  },
   mounted() {
    this.id = localStorage.getItem("user");
    this.getCollectById(this.id).then((res) => {
       let data = res.data.result;
        data.forEach((element) => {
          element.cover = [];
          if (element.photoA !== null && element.photoA !== undefined) {
            element.cover.push(element.photoA);
          }
          if (element.photoB !== null && element.photoB !== undefined) {
            element.cover.push(element.photoB);
          }
          if (element.photoC !== null && element.photoC !== undefined) {
            element.cover.push(element.photoC);
          }
          this.arr.push(element);
        });
    });
  },
};
</script>


<style lang="less" scoped>
.star{
  background-color: #eee;

}
body {
  overflow-x: hidden;
  overflow-y: hidden;
}
.single {
  padding: 15px 12px;
  box-sizing: border-box;
  display: flex;
  justify-content: space-between;
  border-bottom: 1px solid #ccc;
  flex-wrap: wrap;
  .left {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    overflow: hidden;
    .content {
      font-size: 14px;
      padding: 0px 5px;
      line-height: 24px;
      display: -webkit-box;
      -webkit-box-orient: vertical;
      -webkit-line-clamp: 2;
      overflow: hidden;
      text-overflow: ellipsis;
    }
  }
  .info {
    font-size: 12px;
    padding-left: 5px;
    color: #999;
    > span:nth-of-type(1) {
      padding-right: 15px;
    }
  }
  img {
    width: 120/360 * 100vw;
    height: 70/360 * 100vw;
    object-fit: cover;
    padding-right: 5px;
  }
  .imgs {
    display: flex;
    padding: 10px 0 0 0;
    > img {
      flex: 1;
      padding: 0 5px;
      box-sizing: border-box;
      display: block;
    }
  }
  .video {
    width: 100%;
    height: 170/360 * 100vw;
    padding: 10px;
    box-sizing: border-box;
    > img {
      width: 100%;
      height: 100%;
    }
  }
}
</style>